package com.uuah.server.config.spring.parsers.specific;

import org.w3c.dom.Element;

import com.uuah.server.config.Constants;
import com.uuah.server.config.spring.parsers.generic.ChildDefinitionParser;

/**
 * Extend {@link com.uuah.server.config.spring.parsers.generic.ChildDefinitionParser} to
 * include logic for identifying parent configuration element (since this only
 * applies to "default" elements there's an ugliness here - contradicitions
 * (non-default children of configuration) are avoided by the uuah.xsd schema).
 */
public class ConfigurationChildDefinitionParser extends ChildDefinitionParser {

	public static final String CONFIGURATION = "configuration";

	public ConfigurationChildDefinitionParser(String setterMethod, Class clazz) {
		super(setterMethod, clazz);
	}

	protected String getParentBeanName(Element element) {
		if (CONFIGURATION.equals(element.getParentNode().getLocalName())) {
			return Constants.OBJECT_UUAH_CONFIGURATION;
		} else {
			return super.getParentBeanName(element);
		}
	}

}
